<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <title>信息管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="/style/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script type="text/javascript" src="/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/jquery/plugins/jquery.form.min.js"></script>
    <script type="text/javascript" src="/js/commonAll.js"></script>
    <script type="text/javascript" src="/js/jquery/plugins/jquery.validate.js"></script>
    <script type="text/javascript">
	  	$(function(){
	  		 $("#editForm").validate({
	  			rules: {
	  				name:{
	  					required: true,
	  					rangelength:[5,10]
	  				},
	  				password:{
	  					required:true,
	  					rangelength:[6,18]
	  				},
	  				repassword:{
	  					required:true,
	  					equalTo:'#password'
	  				},
	  				email:{
	  					required:true,
	  					email:true
	  				},
	  				age:{
	  					required:true,
	  					range:[18,60]
	  				}
	  			},
	  			messages: {
	  				name:{
	  					required: "必填",
	  					rangelength:"长度为5~10之间"
	  				},
	  				password:{
	  					required:"必填",
	  					rangelength:"至少6位,长度为6~18之间"
	  				},
	  				repassword:"必须与密码保持一致",
	  				email:{
	  					required:"必填",
	  					email:"必须是邮件格式:例 12345@qq.com"
	  				},
	  				age:{
	  					required:"必填",
	  					range:"年龄在18~60岁之间"
	  				}
	  			}
	  		});
	  	});
    </script>
</head>
<body>
<form name="editForm" action="/employee/saveOrUpdate" method="post" id="editForm">
	<input type="hidden" name="id" value="${employee.id}">
    <div id="container">
        <div id="nav_links">
            <span style="color: #1A5CC6;">用户${empty employee ? '添加' : '编辑'}</span>
            <div id="page_close">
                <a>
                    <img src="/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/>
                </a>
            </div>
        </div>
        <div class="ui_content">
            <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0">
                <tr>
                    <td class="ui_text_rt" width="140">用户名</td>
                    <td class="ui_text_lt">
                        <input name="name" value="${employee.name}" class="ui_input_txt02"/>
                    </td>
                </tr>
                <c:if test="${employee==null}">
	                <tr>
	                    <td class="ui_text_rt" width="140">密码</td>
	                    <td class="ui_text_lt">
	                        <input type="password" name="password" id="password" class="ui_input_txt02"/>
	                    </td>
	                </tr>
	                <tr>
	                    <td class="ui_text_rt" width="140">验证密码</td>
	                    <td class="ui_text_lt">
	                        <input name="repassword" type="password" class="ui_input_txt02" />
	                    </td>
	                </tr>
                </c:if>
                <tr>
                    <td class="ui_text_rt" width="140">Email</td>
                    <td class="ui_text_lt">
                        <input name="email" value="${employee.email}"  class="ui_input_txt02"/>
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">年龄</td>
                    <td class="ui_text_lt">
                        <input name="age" value="${employee.age}"  class="ui_input_txt02"/>
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">所属部门</td>
                    <td class="ui_text_lt">
                        <select name="dept.id" class="ui_select01">
                            <option value="-1">全部</option>
                        	<c:forEach items="${departments}" var="d">
                          	  <option value="${d.id}" ${d.id==employee.dept.id ? 'selected':''}>${d.name}</option>
                        	</c:forEach>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="ui_text_rt" width="140">超级管理员</td>
                    <td class="ui_text_lt">
                        <input type="checkbox" name="admin" ${employee.admin ?'checked':''} class="ui_checkbox01"></input>
                    </td>
                </tr>
                
                <tr>
                    <td class="ui_text_rt" width="140">角色</td>
                    <td class="ui_text_lt">
                        <table>
                            <tr>
                                <td>
                                    <select id="select1" multiple="true" class="ui_multiselect01">
                                    	<c:forEach items="${roles}" var="r">
                                    		<option value="${r.id}">${r.name}</option>
                                    	</c:forEach>
                                    </select>
                                </td>
                                <td align="center">
                                    <input type="button" id="select" value="-->" class="left2right"/><br/>
                                    <input type="button" id="selectAll" value="==>" class="left2right"/><br/>
                                    <input type="button" id="deselect" value="<--" class="left2right"/><br/>
                                    <input type="button" id="deselectAll" value="<==" class="left2right"/>
                                </td>
                                <td>
                                    <select id="select2" name="ids" multiple="true" class="ui_multiselect01">
                                    	<c:forEach items="${employee.roles}" var="r">
                                    		<option value="${r.id}">${r.name}</option>
                                    	</c:forEach>
                                    </select>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td class="ui_text_lt">
                        &nbsp;<input type="submit" value="确定保存" class="ui_input_btn01"/>
                        &nbsp;<input id="cancelbutton" type="reset" value="重置" class="ui_input_btn01"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>